# ------------------- Dashboard Deployment ------------------- #

kind: Deployment
apiVersion: apps/v1
metadata:
  labels:
    app: kube-dashboard
  name: kube-dashboard
  namespace: kube-system
spec:
  replicas: 1
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      app: kube-dashboard
  template:
    metadata:
      labels:
        app: kube-dashboard
    spec:
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - preference:
                matchExpressions:
                - key: dashboard
                  operator: In
                  values:
                  - turnon
              weight: 100
      priorityClassName: system-cluster-critical
      containers:
      - name: kube-dashboard
        image: {{addons_ip3}}:5000/kubernetes-dashboard-amd64:{{k8sdashboardversion}}
        imagePullPolicy: IfNotPresent
        resources:
          limits:
            cpu: 100m
            memory: 300Mi
          requests:
            cpu: 50m
            memory: 100Mi
        ports:
        - containerPort: 8443
          protocol: TCP
        args:
          - --auto-generate-certificates
          # Uncomment the following line to manually specify Kubernetes API server Host
          # If not specified, Dashboard will attempt to auto discover the API server and connect
          # to it. Uncomment only if the default does not work.
          # - --apiserver-host=http://my-address:port
          - --apiserver-host=https://{{master_vip}}:{{master_vport}}
          - --kubeconfig=/etc/kubernetes/ssl/kube.kubeconfig
          - --token-ttl=66666
        volumeMounts:
        - name: run
          mountPath: /etc/kubernetes/ssl/kube.kubeconfig
          readOnly: true
        - name: kubernetes-dashboard-certs
          mountPath: /certs
          # Create on-disk volume to store exec logs
        - mountPath: /tmp
          name: tmp-volume
        livenessProbe:
          httpGet:
            scheme: HTTPS
            path: /
            port: 8443
          initialDelaySeconds: 30
          timeoutSeconds: 52
      volumes:
      - name: run
        hostPath:
          path: /etc/kubernetes/ssl/kube.kubeconfig
      - name: kubernetes-dashboard-certs
        secret:
          secretName: kubernetes-dashboard-certs
      - name: tmp-volume
        emptyDir: {}
      serviceAccountName: kubernetes-dashboard
      imagePullSecrets:
      - name: harbor-secret
